package homework.day05;

/**
 * @author ThinkBook
 */
public class Test11 {
    public static void main(String[] args) {
//借助三参构造器 实例化对象
        Duration d1 = new Duration(1,1,1);
//获取总秒数
        int totalSeconds = d1.getTotalSeconds();
        System.out.println("1小时1分钟1秒：" + totalSeconds);
        System.out.println("------------------");
//借助单参构造器 实例化对象
        Duration d2 = new Duration(3660);
//获取小时
        int hour = d2.getHour();
        System.out.println("hour = " + hour);
        System.out.println("------------------");
//输出对象属性信息及总描述信息
        d2.disp();
    }
}
//基础类定义
class Duration {
    private int hour;
    private int min;
    private int sec;
//补全下面代码
    public Duration(){

    }
    public Duration(int hour,int min, int sec){
        this.hour = hour;
        this.min = min;
        this.sec = sec;
    }
    public Duration(int seconds){
        this.hour = seconds / 3600;
        this.min = (seconds % 3600) / 60;
        this.sec = seconds % 60;
    }
    public int getHour(){
        return hour;
    }
    public int getMin(){
        return min;
    }
    public int getSec(){
        return sec;
    }
    public int getTotalSeconds(){
        int seconds;
        seconds = hour*3600 +min*60+sec;
        return seconds;
    }
    public void disp(){
        System.out.println("小时"+this.hour);
        System.out.println("分"+this.min);
        System.out.println("秒"+this.sec);
        System.out.println("总秒数"+getTotalSeconds());
    }
}
